package com.zuikaku;

import com.zuikaku.task.FixExcelTask;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.*;

public class Main {

    public static void main(String[] args){
        System.out.println(
                " ▄▄▄▄▄▄   ▀           ▄▄▄▄▄▄                      ▀▀█   \n" +
                " █      ▄▄▄    ▄   ▄  █      ▄   ▄   ▄▄▄    ▄▄▄     █   \n" +
                " █▄▄▄▄▄   █     █▄█   █▄▄▄▄▄  █▄█   █▀  ▀  █▀  █    █   \n" +
                " █        █     ▄█▄   █       ▄█▄   █      █▀▀▀▀    █   \n" +
                " █      ▄▄█▄▄  ▄▀ ▀▄  █▄▄▄▄▄ ▄▀ ▀▄  ▀█▄▄▀  ▀█▄▄▀    ▀▄▄ \n" +
                        "Excel批量修复工具by nanoda");
        ResourceBundle rb =ResourceBundle.getBundle("config");
        String inputPath =new String( rb.getString("fix.inputFolder").getBytes(StandardCharsets.ISO_8859_1),StandardCharsets.UTF_8);
        String outputPath =new String( rb.getString("fix.outputFolder").getBytes(StandardCharsets.ISO_8859_1),StandardCharsets.UTF_8);
        System.out.println("配置 inputFolder："+inputPath);
        System.out.println("配置 outputFolder："+outputPath);
        File outFolder =new File(outputPath);
        if(!outFolder.exists()){
            outFolder.mkdir();
        }


        FutureTask<List<String>> task =new FutureTask<>(new FixExcelTask(inputPath,outputPath));
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        executorService.submit(task);

        try {
            List<String> result = task.get();
            System.out.println("处理失败的文件如下：");
            result.forEach(System.out::println);
            executorService.shutdown();
        } catch (InterruptedException | ExecutionException e1) {
            e1.printStackTrace();
        }
    }
}
